package com.uhylab.uhuvinetest.activity;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.TextView;

import com.uhylab.uhuvinetest.R;
import com.uhylab.uhuvinetest.base.UHBaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 项目名称：Uhylab
 * 类描述：
 * 创建人：xyb
 * 创建时间：16/8/25 10:21
 * 修改人：xyb
 * 修改时间：16/8/25 10:21
 * 修改备注：
 */
public class UHNewsWebActivity extends UHBaseActivity {
    @BindView(R.id.news_title)
    TextView mNewsTitle;
    @BindView(R.id.webView_back)
    ImageView mWebViewBack;
    @BindView(R.id.webView_news)
    WebView mWebViewNews;
    private String id;
    private String title;
    private String loadUrl;

    @Override
    public int bindLayout() {
        return R.layout.activity_newsweb;
    }

    @Override
    public void initView(View view) {
        ButterKnife.bind(this);
        Intent intent = getIntent();
        id = intent.getStringExtra("id");
        title = intent.getStringExtra("title");
        loadUrl = intent.getStringExtra("url");

    }

    @SuppressLint("SetJavaScriptEnabled")
    @Override
    public void doBusiness(Context mContext) {
        WebSettings settings = mWebViewNews.getSettings();
        settings.setJavaScriptEnabled(true);
        mWebViewNews.setWebViewClient(new WebViewClient());
        mNewsTitle.setText(title);
        initNet(loadUrl);
    }

    private void initNet(String loadUrl) {
        mWebViewNews.loadUrl(loadUrl);
    }

    @Override
    public void resume() {

    }

    @Override
    public void destroy() {

    }


    @OnClick({R.id.news_title, R.id.webView_back})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.news_title:
                break;
            case R.id.webView_back:
                finish();
                break;
        }
    }
}
